package nl.windgazer.facebook.components;

import nl.windgazer.arachne.services.facebook.FacebookAPISettings;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.annotations.BeforeRenderTemplate;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;

public class Comments extends XFBMLElement {

	//Injects and Persists

	@Inject
	private FacebookAPISettings _fb;

	//Properties and Parameters

	@Parameter(required = false, principal = false, defaultPrefix = BindingConstants.PROP, name = "numposts")
	private Integer _numposts = 10;

	@Parameter(required = false, principal = false, defaultPrefix = BindingConstants.PROP, name = "publish_feed")
	private boolean _publish_feed = true;

	//Components

	//Events

	@BeforeRenderTemplate
	void setupCommentsSettings() {
		_fb.setCookie(true);
		_fb.setStatus(true);
		setTag("comments");
		setAttribs("numposts", _numposts.toString(), "publish_feed", String.valueOf(_publish_feed));
	}

	//Other (check for business-logic, it should not remain here)

}
